﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
namespace Social_Photos
{
    public partial class GoogleMap : PhoneApplicationPage
    {
        int zoom = 17;
        int currentZoom;
        string latitude;
        string longtitude;
        public GoogleMap()
        {
            InitializeComponent();
            
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            latitude = NavigationContext.QueryString["latitude"];
            longtitude = this.NavigationContext.QueryString["longtitude"];
            displayLocationPhoto(zoom);
        }

        public void displayLocationPhoto(int _zoom)
        {
            Uri uri = new Uri("http://maps.googleapis.com/maps/api/staticmap?center=" + latitude+","+ longtitude+"&zoom="+_zoom+"&size=480x600&sensor=false");
            BitmapImage bmp = new BitmapImage(uri);
            PhotoImage.Source = bmp;
        }

        private void ButtonZoomOut_Click(object sender, RoutedEventArgs e)
        {
            currentZoom = zoom;
            zoom--;
            displayLocationPhoto(zoom);
        }

        private void ButtonZoomIn_Click(object sender, RoutedEventArgs e)
        {
            currentZoom = zoom;
            zoom++;
            displayLocationPhoto(zoom);
        }

        /*------------------------------------------GESTURE---------------------------------------------*/
        double initialAngle;
        double initialScale;

        private void OnTap(object sender, GestureEventArgs e)
        {
            transform.TranslateX = transform.TranslateY = 0;
        }

        private void OnDoubleTap(object sender, GestureEventArgs e)
        {
            transform.ScaleX = transform.ScaleY = 1;
        }

        private void OnHold(object sender, GestureEventArgs e)
        {
            transform.TranslateX = transform.TranslateY = 0;
            transform.ScaleX = transform.ScaleY = 1;
            transform.Rotation = 0;
        }


        private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
        {
            //  border.Background = redBrush;

          //  initialAngle = transform.Rotation;
            initialScale = transform.ScaleX;

        }

        private void OnPinchDelta(object sender, PinchGestureEventArgs e)
        {
          //  transform.Rotation = initialAngle + e.TotalAngleDelta;
            transform.ScaleX = transform.ScaleY = initialScale * e.DistanceRatio;
            double ab = e.TotalAngleDelta;
  
            
        }

        private void OnPinchCompleted(object sender, PinchGestureEventArgs e)
        {
            //  border.Background = normalBrush;
        }

        private void OnFlick(object sender, FlickGestureEventArgs e)
        {
            //flickData.Text = string.Format("{0} Flick: Angle {1} Velocity {2},{3}",
            //    e.Direction, Math.Round(e.Angle), e.HorizontalVelocity, e.VerticalVelocity);
        }

    }
}